<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jsTree test</title>
<!-- 2 load the theme CSS file -->
<%@include file="/WEB-INF/jsp/admin/public/cssHeader.jsp"%>
<%@include file="/WEB-INF/jsp/admin/public/jsBottom.jsp"%>
</head>
<body>
	<!-- 3 setup a container element -->
	<div id="jstree">
		<!-- in this example the tree is populated from inline HTML -->
		<ul>
			<c:forEach var="item" items="${resources }">
				<li id="${item.id }">${item.name}
					<c:if test="${item.childBeans != null}">
						<ul>
							<c:forEach var="item1" items="${item.childBeans }">
								<li id="${item1.id }">${item1.name }
									<c:if test="${item1.childBeans != null}">
										<ul>
											<c:forEach var="item2" items="${item1.childBeans}">
											<li id="${item2.id }">
												${item2.name }
											</li>
											</c:forEach>
										</ul>
									</c:if>
								</li>
							</c:forEach>
						</ul>
					</c:if>
				</li>
			</c:forEach>
		</ul>
	</div>

	<script>
		$(function() {
			//生成jstree数
			$('#jstree').jstree();
			//监听生成数节点
			$('#jstree').on("activate_node.jstree", function(e, data) {
				// 节点的id
				var id = data.node.id;
				// 节点标签内容
				var text = data.node.text;
				// 设置父节点属性
				var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
				console.log(parent.$('#parentResName').val(text));
				console.log(parent.$('#parentResId').val(id));
				parent.layer.close(index);
			});
		});
	</script>
</body>
</html>

